package org.example.seckill.util;

import org.apache.commons.codec.digest.DigestUtils;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 * @author woopsion
 * @date 2025-06-28
 */
public class MD5util {
    public static String getMD5(String s)  {
        return DigestUtils.md5Hex(s);
    }
    private static final String SALT = "cLo8QmTG";
    
    public static String inputToMD5wtSalt(String s)  {
        return getMD5(SALT.charAt(0)+s+SALT.charAt(6));
    }
    
    public static String midPassToDBPass(String midPass, String salt){
        return getMD5(salt.charAt(1)+midPass+salt.charAt(5));
    }
    public static String inputToDBPass(String inputPass, String salt){
        String s = inputToMD5wtSalt(inputPass);
        String s1 = midPassToDBPass(s, salt);
        return s1;
    }
}
